/*
 *
 */
function layoutInit() {
	var ps = tb_getPageSize(); // 注意: tb_getPageSize 函数在jquery的thickbox.js里面

	var hd_h = document.getElementById("header").offsetHeight;
	var ft_h = 0;
	var lf_w = 190;

	var tmp1 = 0;
	var tmp2 = 0;
	if (!$.browser.msie) {
		tmp1 = 0;
		tmp2 = 2;
	}
	var ct_h = ps[1] - hd_h - ft_h - tmp1;
	var ct_w = ps[0] - lf_w - tmp2;

	// $("#header").css("height", hd_h + "px");
	$("#footer").css("height", ft_h + "px");
	$("#left").css("width", lf_w + "px");
	$("#left").css("height", ct_h + "px");
	$("#content").css("width", ct_w + "px");
	$("#content").css("height", ct_h + "px");

	var toolbar_h = document.getElementById("toolbar").offsetHeight;
	var ctm_h = ct_h - toolbar_h;
	if (!$.browser.msie) {
		ctm_h = ctm_h - 20;
	}
	$("#content_main").css("height", ctm_h + "px");

	// 窗口大小变化时重新设置布局
	if ($.browser.msie) {
		$("#box").resize(layoutInit);
	} else {
		window.onresize = layoutInit;
	}
}

/**
 * 
 * @return
 */
function initDialog() {
	if (typeof document.body.style.maxHeight === "undefined") {// if IE 6
		if (document.getElementById("dialog_HideSelect") === null) {
			// iframe to hide select elements in ie6
			$("body")
					.append(
							"<iframe id='dialog_HideSelect'></iframe><div id='dialog_overlay'></div><div id='dialog_window'></div>");
		}
	} else {
		// all others
		if (document.getElementById("dialog_overlay") === null) {
			$("body")
					.append(
							"<div id='dialog_overlay'></div><div id='dialog_window'></div>");
		}
	}
	$("#dialog_window")
			.append(
					"<div id='dialog_title'><div id='dialog_windowTitle'>"
							+ "</div><div id='dialog_closeWindow'>"
							+ "<a href='#' id='dialog_closeWindowButton'>close</a></div></div>"
							+ "<div id='dialog_content'></div>");
	// dialog
	$('#dialog_closeWindow').click(closeDialog);
}
function closeDialog() {
	$("#dialog_window").hide();
	$("#dialog_overlay").hide();
}
function showDialog(dialogWidth, dialogHeight) {
	if (dialog_detectMacXFF()) {
		$("#dialog_overlay").addClass("dialog_overlayMacFFBGHack");
		// use png overlay so hide flash
	} else {
		$("#dialog_overlay").addClass("dialog_overlayBG");
		// use background and opacity
	}
	//
	var d_width = dialogWidth + 30 || 630; //defaults to 630 if no paramaters were added to URL
	var d_height = dialogHeight + 40 || 440; //defaults to 440 if no paramaters were added to URL
	var d_contentW = d_width - 30;
	var d_contentH = d_height - 45;
	//
	dialog_position(d_width, d_height);
	$("#dialog_content").css("width", "" + d_contentW + "px");
	$("#dialog_content").css("height", "" + d_contentH + "px");
	$("#dialog_overlay").css("display", "block");
	//
	$("#dialog_window").css("display", "block");
}
function dialog_position(d_width, d_height) {
	$("#dialog_window").css( {
		marginLeft :'-' + parseInt((d_width / 2), 10) + 'px',
		width :d_width + 'px'
	});
	if (!(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6
		$("#dialog_window").css( {
			marginTop :'-' + parseInt((d_height / 2), 10) + 'px'
		});
	}
}
function dialog_detectMacXFF() {
	var userAgent = navigator.userAgent.toLowerCase();
	if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox') != -1) {
		return true;
	}
}